#ifndef JSONHELP_H
#define JSONHELP_H

#include <QObject>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
class QTabWidget;

class QJsonParseError;
class jsonHelp : public QObject
{
    Q_OBJECT
public:
    explicit jsonHelp(QObject *parent = 0);

    bool insertData();
    QJsonArray insertGroup(QString groupName,QString ipadd = "");
    QJsonObject insertEach(QString tbname, QStringList strBoxnum, QHash<QString,QString>m_mapvalue, QMap<QString,QString>m_mapPutvalue);
    QJsonObject insertEach(QString tbname, QStringList strBoxnum, QMap<QString,QString>m_mapvalue, QMap<QString,QString>m_mapPutvalue);
    void updateWidget(QTabWidget *tab = 0);

    bool readData(QString filename = "", QJsonObject &mainobj = QJsonObject());
    bool readData(QDateTime datetime);
signals:

public slots:

private:
    QJsonObject parseMain(QByteArray byte_array, QJsonParseError *json_error);
    void parseData(QByteArray byte);

    QJsonArray parseGroup(QString groupname, bool &isExist);
    void parseEach();

    QString m_recordDir;
    QString m_recordFile;
    QJsonObject mainobj;

    QJsonArray m_pugGroup;

    QJsonObject m_putEach;
    QJsonParseError m_parseerror;

    void paraseGroupForTab(QJsonObject obj, QTabWidget *tabWidgetIn/*sub tab widget*/,int index = -1);


};

#endif // JSONHELP_H
